﻿package Classes.Bonus{
	import flash.events.Event;	
	
	import Classes.Elements.*;
	import Classes.Utils.*;
	import Classes.Weapons.*;
	import Classes.Weapons.Bullets.*;
	import Classes.Player.*;
	import Classes.Interface.*;
	
	public class Bonus extends Aero implements IBonus{
		private var radius:Number;
		private var crtr:Number;
		public var tmpx:Number,tmpy:Number;
		protected var enable:Boolean;
		public function Bonus(){			
			speed = 1.5;
			life = 10000;
			hp = 10000;
			explodeable = false;
			radius 		= 60;
			crtr		= 1;
			accelerate	= 1;
			hittestable = true;
			enable = true;
			addEventListener(Event.ENTER_FRAME,onEnterFrame,false,0,true);
		}		
		override protected function onEnterFrame(e:Event):void{
			if(isInRange())
				move();
		}		
		override protected function move():void{			
			if(crtr<radius)
				crtr += accelerate;
			Moving.moveCircle(this,speed,crtr,inc,tmpx,tmpy+inc/3*speed);
			inc++;	
			hitTest();
		}	
		
		override protected function hitTest():void{
			if(!hittestable)
				return;
			for(var i:int = 0;i<aTargets.length;i++){
				var t:Fighter = aTargets[i] as Fighter;
				if(HitTest.hitTestPoint(this,t)){										
					hittestable = false;	
					doBonus(t);
					this.killer = t;
					t.score += this.score;
					this.erasable = true;
					return;
				}
			}
		}
		public function doBonus(f:Fighter):void{
		}
	}
}